package com.exam.kotlindemo

import org.junit.Test

import org.junit.Assert.*

/**
 * Example local unit test, which will execute on the development machine (host).
 *
 * See [testing documentation](http://d.android.com/tools/testing).
 */
class ExampleUnitTest {
    @Test
    fun addition_isCorrect() {
        assertEquals(4, 2 + 2)
    }

    @Test
    fun testMe(){
//        print(sum(b = 3))
//        val d = Me::me
//        Me("一年").me()
//        val v = fun(){
//            Me::me.invoke(Me("科技的说法"))
//            Me("skjldkls").me()
//        }
//        v.invoke()
        val asss = this::sum
//        asss.invoke(0,4)
//        print(asss.invoke(b = 4))
        print(sum(b = 4))
    }

    fun sum(a: Int = 0, b: Int): Int {   // Int 参数，返回值 Int
        return a + b
    }

    class Me(var args:String){
        @Test
        fun me(){
            //类型后面加?表示可为空
            var age:String? = "2w"
            //抛出空指针异常
            age = "null";
//            val ages = age.toInt()
            print(age + args)
            //不做处理返回 null
//            val ages1 = age.toInt()
            //age为空返回-1
//            val ages2 = age.toInt() ?: -1
        }
    }
}